package com.hunnyhu.tools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Utils {
	
	public static final String YYYY_MM_DD_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
	public static final String YYYY_MM_DD = "yyyy-MM-dd";
	
	public static String dateToString(Date date, String format) {
		if (null == date || null == format) {
			return null;
		}
		return new SimpleDateFormat(format).format(date);
	}
	
	public static Date stringToDate(String sDate, String format) {
		try {
			return new SimpleDateFormat(format).parse(sDate);
		} catch (Exception e) {
		}
		return null;
	}
	
	public static String dateToString(Date date) {
		return dateToString(date, YYYY_MM_DD_HH_mm_ss);
	}
	

}
